package applet;

import java.util.Calendar;
import java.util.Date;

import processing.core.PApplet;
import processing.core.PImage;
import de.fhpotsdam.unfolding.geo.Location;
import de.fhpotsdam.unfolding.marker.Marker;
import de.fhpotsdam.unfolding.marker.MarkerManager;
//import de.fhpotsdam.unfolding.providers.Google;
//import de.fhpotsdam.unfolding.providers.Google.GoogleMapProvider;
import de.fhpotsdam.unfolding.utils.MapUtils;
import de.fhpotsdam.unfolding.mapdisplay.MapDisplayFactory.*;

public class MyMap {
	
	//private GoogleMapProvider gMap;
	de.fhpotsdam.unfolding.Map map;
	float panLat, panLon;
	int zoomLevel;
	
	public MyMap(){
		  //gMap = new Google.GoogleMapProvider();
		  
		  //map = new de.fhpotsdam.unfolding.Map(GLOBAL.processing, 200f, 24f, 800f, 600f, gMap);
		  map = new de.fhpotsdam.unfolding.Map(GLOBAL.processing,"map", GLOBAL.tabs.tagWidth, 0f, 1024f-GLOBAL.tabs.tagWidth, 768f);
		  //map = new de.fhpotsdam.unfolding.Map(GLOBAL.processing,"map", GLOBAL.tabs.tagWidth, 0f, 1024f-GLOBAL.tabs.tagWidth, 768f, true, false, new de.fhpotsdam.unfolding.providers.OpenStreetMap.CloudmadeProvider(de.fhpotsdam.unfolding.mapdisplay.MapDisplayFactory.OSM_API_KEY,30635));
		  //map.setTweening(true);
		  panLat = 15.0f;
		  panLon = 0f;
		  zoomLevel = 2;
		  map.zoomAndPanTo(new Location(panLat, panLon), zoomLevel);
		  //map.zoomToLevel(2);
		  //map.panTo(new Location(41f+53f/60f, -87f-37.7f/60f));
		  map.setZoomRange(2.0f,5.0f);
		  //map.setScaleRange(16.0f, 16384.0f);
		  MapUtils.createDefaultEventDispatcher(GLOBAL.processing, map);

	}
	
	public void draw(){
		drawMap();


	}
	
	public void drawMap(){
		map.draw();
	}
	
	public void saveZoomAndPan() {
		panLat = map.getLocationFromScreenPosition(GLOBAL.tabs.tagWidth/2+512f, 384f).x;
		panLon = map.getLocationFromScreenPosition(GLOBAL.tabs.tagWidth/2+512f, 384f).y;
		zoomLevel = (int)map.getZoomLevel();
	}
	public void loadZoomAndPan() {
		  map.zoomAndPanTo(new Location(panLat, panLon), zoomLevel);
	}
}
